package com.ruoyi.nongjt.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.nongjt.domain.NjtJobPlatform;
import com.ruoyi.nongjt.mapper.NjtJobPlatformMapper;
import com.ruoyi.nongjt.service.NjtJobPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class NjtJobPlatformServiceImpl implements NjtJobPlatformService {
    @Autowired
    private NjtJobPlatformMapper njtJobPlatformMapper;

    @Override
    public List<NjtJobPlatform> getNjtJobPlatformList(NjtJobPlatform njtJobPlatform) {
        return njtJobPlatformMapper.selectNjtJobPlatformList(njtJobPlatform);
    }

    @Override
    public int updateNjtJobPlatform(NjtJobPlatform njtJobPlatform) {
        njtJobPlatform.setUpdateBy(SecurityUtils.getUsername());
        njtJobPlatform.setUpdateTime(new Date());
        return njtJobPlatformMapper.updateNjtJobPlatform(njtJobPlatform);
    }

    @Override
    public int deleteById(Long id) {
        return njtJobPlatformMapper.deleteById(id);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchDeleteJobPlatform(List<Long> ids) {
        // 调用 Mapper 层批量删除方法
        return njtJobPlatformMapper.batchDeleteJobPlatformByIds(ids);
    }
    @Override
    public int addNjtJobPlatform(NjtJobPlatform njtJobPlatform) {
        njtJobPlatform.setUpdateBy(SecurityUtils.getUsername());
        njtJobPlatform.setUpdateTime(new Date());
        return njtJobPlatformMapper.addNjtJobPlatform(njtJobPlatform);
    }

}